package com.app.twth.ui.b2ctrailer;


import com.app.twth.app.Constant;
import com.app.twth.base.BaseModel;
import com.app.twth.bean.BaseResponseEntity;
import com.app.twth.net.JsonCallBack;
import com.app.twth.ui.b2ctrailer.submit.B2CTrailerSubmitQr;
import com.app.twth.utils.GsonUtil;
import com.lzy.okgo.OkGo;

import java.util.HashMap;
import java.util.Map;

public class B2CTrailerDataModel extends BaseModel {
    public <T> void b2cTrailerInitInfo(JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>get(Constant.b2cTrailerInitInfo)
                .tag(this)
                .execute(jsonCallBack);
    }

    public <T> void b2cTrailerEntryTrailer(String trailerNo, JsonCallBack jsonCallBack) {
        Map<String, String> map = new HashMap<>();
        map.put("trailerNo", trailerNo);
        OkGo.<BaseResponseEntity<T>>get(Constant.b2cTrailerEntryTrailer)
                .tag(this)
                .params(map)
                .execute(jsonCallBack);
    }

    public <T> void b2cTrailerRemove(int detailId, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>delete(Constant.b2cTrailerRemove + "/" + detailId)
                .tag(this)
                .execute(jsonCallBack);
    }

    public <T> void b2cTrailerCheckObLpn(String obLpn, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>get(Constant.b2cTrailerCheckObLpn+"/"+obLpn)
                .tag(this)
                .execute(jsonCallBack);
    }

    public <T> void b2cTrailerSubmit(B2CTrailerSubmitQr b2CTrailerSubmitQr, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>post(Constant.b2cTrailerSubmit)
                .tag(this)
                .upJson(GsonUtil.toJson(b2CTrailerSubmitQr))
                .execute(jsonCallBack);
    }
}